package com.yh.manage.course.controller;

import com.lxw.api.course.CourseControllerApi;
import com.lxw.framework.domain.cms.response.CoursePreviewResult;
import com.lxw.framework.domain.course.ext.CourseView;
import com.lxw.framework.model.response.QueryResponseResult;
import com.lxw.framework.model.response.ResponseResult;
import com.yh.manage.course.service.CourseService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("course/")
public class CourseController implements CourseControllerApi {

    @Resource
    private CourseService courseService;

    @GetMapping("cms/page/list")
    @Override
    public QueryResponseResult findCmsPageList(Integer page, Integer size) {
        return courseService.findCmsPageList(page,size);
    }

    @Override
    @GetMapping("/courseview/{id}")
    public CourseView findCourseById(@PathVariable String id) {
        return courseService.findCourseById(id);
    }

    @Override
    @PostMapping("/preview/{id}")
    public CoursePreviewResult preview(@PathVariable String id) {
        return courseService.preview(id);
    }

    @Override
    @PostMapping("/publish/{id}")
    public ResponseResult post(@PathVariable String id) {
        return courseService.post(id);
    }


}
